package com.jiangyg.mall.order.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.order.dao.PaymentInfoDao;
import com.jiangyg.mall.order.dto.PaymentInfoDTO;
import com.jiangyg.mall.order.entity.PaymentInfo;
import com.jiangyg.mall.order.vo.PaymentInfoVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PaymentInfoServiceImpl extends BaseServiceImpl<PaymentInfoDao, PaymentInfo> implements PaymentInfoService {

    @Autowired
    public PaymentInfoServiceImpl(PaymentInfoDao paymentInfoDao) {
        super(paymentInfoDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<PaymentInfoVO> selectPagination(Pagination<PaymentInfoVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, PaymentInfoVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(PaymentInfoDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public PaymentInfoVO selectById(Long paymentInfoId) throws Exception {
        return this.executeSelectById(paymentInfoId, PaymentInfoVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> paymentInfoIds) {
        return this.baseMapper.deleteBatchIds(paymentInfoIds) > 0;
    }

}
